from django.db import models


# Create your models here.
class PostImg(models.Model):
    """图片提交"""
    picture = models.ImageField(upload_to='avatar')


class Manager(models.Model):
    """管理员表"""
    Manager_name = models.CharField(max_length=32, verbose_name="管理员登录名", null=False)
    Manager_password = models.CharField(max_length=32, verbose_name="管理员密码", null=False)


class User(models.Model):
    """用户表"""
    User_name = models.CharField(max_length=32, verbose_name="用户登录名", null=False)
    User_nicheng = models.CharField(max_length=32, verbose_name="用户昵称", default=User_name)
    User_password = models.CharField(max_length=32, verbose_name="用户密码", null=False)
    User_account = models.DecimalField(verbose_name="余额", decimal_places=2, max_digits=22, default=0)
    User_email = models.CharField(verbose_name="用户邮箱", max_length=64)
    User_company = models.CharField(verbose_name="用户公司", max_length=64, null=True)


class Price(models.Model):
    """价格表"""

    price = models.DecimalField(verbose_name='', decimal_places=2, max_length=14, default=1,max_digits=64)


class Record(models.Model):
    """使用记录"""
    oid = models.CharField(verbose_name='订单号', max_length=64, default=0)
    number = models.IntegerField(verbose_name='分析数量', default=0)
    price = models.DecimalField(verbose_name='金额', decimal_places=2, max_digits=64, default=0)
    user = models.ForeignKey(verbose_name="用户", to="User", on_delete=models.CASCADE)


class RechargeOrder(models.Model):
    """充值记录"""
    oid = models.CharField(verbose_name='订单号', max_length=64, default=0)
    user = models.ForeignKey(verbose_name='用户', to='User', on_delete=models.CASCADE)
    price = models.DecimalField(verbose_name='金额', decimal_places=2, max_digits=64)
